package ui.studentManage;

import entity.Student;
import service.StudentService;
import service.impl.StudentServiceImpl;

import java.util.List;
import java.util.Scanner;

import static ui.ManageMenu.showManageMenu;

public class StudentsManageMenu {
    public static final StudentService studentService = new StudentServiceImpl();

    public static void showStudentsManageMenu() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("学生管理界面");
        System.out.println("1、查询所有学生");
        System.out.println("2、根据姓名查询学生");
        System.out.println("3、更新学生信息");
        System.out.println("4、添加学生");
        System.out.println("5、删除学生");
        System.out.println("6、返回上级菜单");
        int option = scanner.nextInt();
        switch (option) {
            case 1:
                List<Student> selectAllStudents = selectAllStudent();
                showStudentsManageMenu();
            case 2:
                List<Student> selectStudentLikeName = selectStudentLikeName();
                showStudentsManageMenu();
            case 3:
                updateStudent();
                showStudentsManageMenu();
            case 4:
                saveStudent();
                showStudentsManageMenu();
            case 5:
                deleteStudent();
                showStudentsManageMenu();
            case 6:
                showManageMenu();
                break;
            default:
                showStudentsManageMenu();
        }
    }

    private static void deleteStudent() {
        System.out.println("TODO:");
        showStudentsManageMenu();
    }

    private static void saveStudent() {
        System.out.println("TODO:");
        showStudentsManageMenu();
    }

    private static void updateStudent() {
        System.out.println("TODO:");
        showStudentsManageMenu();
    }

    private static List<Student> selectStudentLikeName() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("--------输入学生姓名--------");
        String name = scanner.next();
        List<Student> students = studentService.selectStudentLikeName(name);
        System.out.println("--------查询结果---------");
        for (Student student : students) {
            System.out.println(student);
        }
        return students;
    }

    private static List<Student> selectAllStudent() {
        List<Student> students = studentService.selectAllStudents();
        System.out.println("--------查询结果---------");
        for (Student student : students) {
            System.out.println(student);
        }
        return students;
    }
}
